package org.example.pojo;

import org.example.utils.Tool;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Schedule {//一个班级对应一个Schedule
    private int classno = 0;
    private int people = 0;
    private int semester = 0;
    private List<PieceSchedule> pieceSchedules = new ArrayList<>();//对应每个课程和教室
    private Plan plan;//根据课程计划设置课表
    private Tool atool;
    private int C1=2,C2=16,C3=4;//参数可修改,C1为单独优先级、C2为课程类型、C3为人数参数

    public Schedule() { }

    public Schedule(Tool atool,Plan plan) {
        this.atool=atool;
        this.plan=plan;
    }

    public int getClassno() {
        return classno;
    }

    public void setClassno(int classno) {
        this.classno = classno;
    }

    public int getPeople() {
        return people;
    }

    public void setPeople(int people) {
        this.people = people;
    }

    public Plan getPlan() {
        return plan;
    }

    public void setPlan(Plan plan) {
        this.plan = plan;
    }

    public int getSemester() {
        return semester;
    }

    public void setSemester(int semester) {
        this.semester = semester;
    }

    public List<PieceSchedule> getPieceSchedules() {
        return pieceSchedules;
    }

    public void setPieceSchedules(List<PieceSchedule> pieceSchedules) {
        this.pieceSchedules = pieceSchedules;
    }

    public void addPri(){
        for(int i=0;i<plan.getCourses().size();i++) {
            int t[];
            PieceSchedule p=new PieceSchedule();
            p.setCourseno(plan.getCourses(i));
            p.setClassno(classno);
            t=atool.findPri(plan.getCourses(i));
            p.setFinalpri(t[0]*C1+t[1]*C2+people*C3);//设置班级课程的优先级
//            pieceSchedules[i]=p;
            pieceSchedules.add(i,p);
        }
    }//设置pieceSchedule，init有课程无教室

    @Override
    public String toString() {
        return "Schedule{" +
                "classno=" + classno +
                ", people=" + people +
                ", semester=" + semester +
                ", pieceSchedules=" + pieceSchedules +
                ", plan=" + plan +
                '}';
    }
}
